package com.epam.cdp.jpa.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import lombok.EqualsAndHashCode;


@Entity
@Data
@EqualsAndHashCode(callSuper = true)
public class Book extends BaseEntity {

    private static final transient long serialVersionUID = 1L;
    
    private String title;
    private String description;
    private int pageCount;
    
    @Column(unique = true)
    private String isbn;

    @Temporal(value = TemporalType.DATE)
    private Date publicationDate;
    
    private int rating;
    
    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
    private List<Author> authors;
}
